package 注解;

import java.lang.reflect.Field;

/**
 * Created by zzy on 2018/4/8.
 */
public class Test {

    public static void getFruitInfo(String clas){
        try {
            Class<?> cls=Class.forName(clas);
            Field[] fields=cls.getDeclaredFields();

            for(Field field:fields){
                if(field.isAnnotationPresent(FruitName.class)==true){
                    FruitName name=field.getAnnotation(FruitName.class);
                    System.out.println(name.value());
                }
            }

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
